<HTML><HEAD> <!-- ---------------- Mirroring Values ---------------- --> <SCRIPT LANGUAGE="JavaScript"><!-- hide from old browsers /* THE JAVASCRIPT COOKBOOK by Erica Sadun, webrx@mindspring.com Copyright (c)1998 by Charles River Media. All Rights Reserved. This applet can only be re-used or modifed by license holders of the JavaScript Cookbook CD-ROM. Credit must be given in the source code and this copyright notice must be maintained. If you do not hold a license to the JavaScript Cookbook, you may NOT duplicate or modify this code for your own use. Use at your own risk. No warranty is given or implied of the suitability of this applet for any specific application. Neither Erica Sadun nor Charles River Media will be held responsible for any unwanted effects due to the use of this applet or any derivative. */ function reflect(aForm) { var myIndex = aForm.units.selectedIndex var myText = aForm.units.options[myIndex].text aForm.result.value = myText } <!-- done hiding --></SCRIPT></HEAD> <BODY bgcolor="ffffff" link="0000ff" vlink="770077"> <FONT COLOR="007777"><H1><IMG SRC="../GRAFX/UTENS.JPG" WIDTH=80 HEIGHT=50 ALIGN = LEFT>Selection Values</H1></FONT> <BLOCKQUOTE><FONT COLOR="770000"> The text field below mirrors the current value of the selection when you press the 'Show Selection' button. </FONT></BLOCKQUOTE> <CENTER><FORM> <SELECT name="units"> <OPTION selected>val_1 <OPTION>val_2 <OPTION>val_3 </SELECT> <INPUT NAME="result" SIZE="20" VALUE="" ><p> <INPUT TYPE="button" VALUE="Show Selection" onClick="reflect(this.form)"> <INPUT TYPE="reset" VALUE="ResetAll"> </FORM></CENTER> <FONT COLOR="007777"><H2>Discussion</H2></FONT> <FONT SIZE=4> This script shows how to access text values from an OPTIONS array and manipulate the value of a TEXT field. </FONT> <FONT COLOR="770000"><PRE> function reflect(aForm) { var myIndex = aForm.units.selectedIndex var myText = aForm.units.options[myIndex].text aForm.result.value = myText } </PRE></FONT> <h5>Copyright ©1996 by Charles River Media, All Rights Reserved</h5> </BODY> </HTML>